package com.fu.jdbc04;

import com.fu.utils.DataSourceUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author 付大大
 * @description
 * @create 2021-01-31 15:46
 */
public class DruidTest2 {
    public static void main(String[] args) throws SQLException {
        Connection connection = DataSourceUtils.getConnection();
        String sql = "select * from student";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            System.out.println(resultSet.getInt("sid") + "\t" + resultSet.getString("name") + "\t"
                    + resultSet.getInt("age") + "\t" + resultSet.getDate("birthday"));
        }
        DataSourceUtils.close(connection, preparedStatement, resultSet);
    }
}
